package com.lg.common.aspect;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.lg.system.log.service.LogService;
@Aspect
@Component
public class LogInterceptor {
	  
	  @Autowired
	  private LogService logService;
	
	  @Around("execution(* com.lg..controller.*.*(..)) && @annotation(com.lg.common.annotation.Logs)")
      public Object doAround(ProceedingJoinPoint pjp) throws Throwable {
		    long starTime = System.currentTimeMillis();
			Object result = pjp.proceed();
			long endTime = System.currentTimeMillis();
			logService.saveLog(pjp, endTime-starTime);
			return result;
      }
	  
}
